// 爆品商品
define(()=>{
function commodity(){
let da = dataList[0].list



da.forEach((item, id) => {
    if (id <= 7) {
        $(".Popularnews ul")[0].innerHTML += `

<li>

<div class="imge">
  <div>
    <img
      src="${item.list_url}"
      alt="">
  </div>
  <p class="p1">${item.list_name} </p>
  <i>3期免息</i>
  <p class="p2">${item.list_price}</p>
</div>

</li>



`

    } else {
        return false;
    }

});

// 分类商品1

$.ajax({
        url: "../data/goods.json",
        type: "get",
        dataType: "json"

    })
    .then(function (res) {
       
        let data= res.slice(0, 30)
        

// 进来就有数据
data.forEach(function (item, id) {

    if (id < 8) {
       
        $("  .goods1 .list")[0].innerHTML += `


<li>
<a href="./html/detailPages.html?id=${item.goods_id}">
<div class="imges">
<img src="${item.img_small_logo}" alt="">
</div>
<p class="p1 texthide ">${item.title} </p>
<i>3期免息</i>
<p class="p2">${item.price}</p>
</a>
</li>




`



    } else {
        return false;
    }

})



        $(" .goods1 .ttop li").click(function () {
            $("  .goods1 .list")[0].innerHTML =""
          
            let mach = Math.floor((Math.random() * 1000 / 5+4))
            // console.log(mach)
            let dat = res.slice(parseInt(mach/3), mach)

            dat.forEach(function (item, id) {

                if (id < 8) {
                   
                    $("  .goods1 .list")[0].innerHTML += `
    
    
    <li>
    <a href="./html/detailPages.html?id=${item.goods_id}">
    <div class="imges">
      <img src="${item.img_small_logo}" alt="">
    </div>
    <p class="p1 texthide ">${item.title} </p>
    <i>3期免息</i>
    <p class="p2">${item.price}</p>
    </a>
  </li>
    
    
    
    
    `



                } else {
                    return false;
                }



            })









        })


    })






// 分类商品2




$.ajax({
    url: "../data/goods.json",
    type: "get",
    dataType: "json"

})
.then(function (res) {
   
    let data= res.slice(60, 90)


// 进来就有数据
data.forEach(function (item, id) {

if (id < 8) {

    $("  .goods2 .list")[0].innerHTML += `


<li>
<a href="./html/detailPages.html?id=${item.goods_id}">
<div class="imges">
<img src="${item.img_small_logo}" alt="">
</div>
<p class="p1 texthide ">${item.title} </p>
<i>3期免息</i>
<p class="p2">${item.price}</p>
</a>
</li>




`



} else {
    return false;
}

})



    $(" .goods2 .ttop li").click(function () {
        $("  .goods2 .list")[0].innerHTML =""
      
        let mach = Math.floor((Math.random() * 1000 / 5+4))
        // console.log(mach)
        let dat = res.slice(parseInt(mach/3), mach)

        dat.forEach(function (item, id) {

            if (id < 8) {
                console.log(item)
                $("  .goods2 .list")[0].innerHTML += `


<li>
<a href="./html/detailPages.html?id=${item.goods_id}">
<div class="imges">
  <img src="${item.img_small_logo}" alt="">
</div>
<p class="p1 texthide ">${item.title} </p>
<i>3期免息</i>
<p class="p2">${item.price}</p>
</a>
</li>




`



            } else {
                return false;
            }



        })









    })


})

}
 return commodity()



})




